package com.zjw.service;

import com.zjw.entity.User;
import com.zjw.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.stereotype.Service;


/**
 * 这个service用来记录事务的回滚测试
 * */
@Service
@Slf4j
public class TransactionExampleService {

    @Autowired
    UserMapper userMapper;

    public User addWithoutTransaction(User user){
        try {
            log.info("开始新增数据");
            userMapper.insert(user);
            int i = 1/0;
        } catch (Exception e) {
            log.error("新增数据异常");
            throw new RuntimeException(e);
        }
        return user;
    }
}
